<!DOCTYPE HTML>
<html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.css"/>
    <link rel="stylesheet" href="/static/plugins/bui/bui.css"/>
    <link rel="stylesheet" type="text/css" href="/static/plugins/layui/css/layui.css"/>
    <link rel="stylesheet" href="/static/plugins/PNotify/pnotify.custom.min.css">
    <link rel="stylesheet" href="/static/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/datepicker/css/datepicker.css">
    <link rel="stylesheet" type="text/css" href="/static/webuploader/webuploader.css">
    <style type="text/css">
        html {
            height: 100%;
        }

        body {
            background: #EFF3FC;
            height: 100%;
        }

        .content {
            margin-left: 0;
            margin-top: 0;
            width: auto;
            padding: 0px 20px 0 20px;
            height: 97%;
        }

        table {
            width: 90%;
            margin: 0 auto;
        }

        tr {
            text-align: center;
        }

        tr:first-child {
            text-align: center;
        }

        tr th {
            text-align: center;
        }

        .searchDetail {
            height: 60px;
            line-height: 60px;
            margin: 0px;
            display: inline-block;
        }

        button, input {
            line-height: normal;
        }

        .officeContent {
            background: #ffffff;
            border-radius: 10px;
            border: 1px solid #cccccc;
            height: 88%;
            margin-bottom: 20px;
        }

        .officeTable {
            height: 81%;
            overflow: scroll;
            overflow-x: hidden;
        }

        .officeTable table {
            width: 95%;
            margin: 0 auto;
            table-layout: fixed;
        }

        .officeTable table tbody tr td:nth-child(2) {
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }

        #demo7 {
            border-top: 1px solid #eeeeee;
            margin-left: 3%;
        }

        .table thead > tr > th, .table tbody > tr > th, .table tfoot > tr > th, .table thead > tr > td, .table tbody > tr > td, .table tfoot > tr > td {
            vertical-align: middle;
        }

        tr td {
            height: 55px;
        {#            overflow: hidden;#}{#            white-space: nowrap;#}{#            text-overflow: ellipsis;#}
        }

        .operationBtn {
            width: 100%;
            padding: 23px;
        }

        .operationBtn button .icon {
            margin-right: 5px;

        }

        .layui-laypage .layui-laypage-curr .layui-laypage-em {
            background-color: #5bc0de;
        }

        .pointer {
            cursor: pointer;
        }

        .searchDetail input {
            height: 34px;
            padding: 6px 12px;
            font-size: 14px;
            line-height: 1.428571429;
            color: #555555;
            vertical-align: middle;
            background-color: #ffffff;
            border: 1px solid #cccccc;
            border-radius: 4px;
        }

        .showHeightSearch {
            background: #ffffff;
            margin-bottom: 10px;
            border-radius: 10px;
            border: 1px solid #cccccc;
            padding-top: 11px;
            padding-right: 80px;
        }

        #thelist .item {
            margin-bottom: 10px;
        }

        #thelist .item:nth-child(odd) {
            background: #f9f9f9;
        }

        .optionType {
            border: 1px solid #9d9d9d;
            background: #ffffff;
            position: absolute;
            border-radius: 5px;
            top: 42%;
            right: 15px;
            z-index: 100;
        }

        .optionType ul {
        {#            padding: 16px;#}

        }

        .optionType ul li {
            padding: 4px 19px 2px 19px;
            text-align: left;
        }

        .optionType ul li:hover {
            background: #f9f9f9;
        }
    </style>
</head>
<body ng-app="logMag" ng-controller="logManageCtrl">
<div class="content">
    <div style="padding: 10px 0;">收集管理
        <span ng-repeat="item in navData" ng-click="navHref(item.id)"><a href="">>{$ item.name $}</a></span>
    </div>
    <div class="searchDetail" ng-show="showSearch">
        <label>题名</label>
        <input type="text" placeholder="" ng-model="title"/>
        <label for="">负责人</label>
        <input type="text" placeholder="" ng-model="personCharge"/>
        <button ng-click="searchSimple()" class="btn  btn-warning" style="padding: 5px 12px;margin-top: -3px;">查询
        </button>
        <button class="btn  btn-warning" style="padding: 4px 12px;border-radius: 4px;" ng-click="heightSearch()">高级查询
        </button>
    </div>
    {#    高級搜索模块#}
    <div class="showHeightSearch ng-hide" ng-show="showHeightSearch">
        <form class="form-horizontal modal-form" name="searchForm" novalidate="novalidate">
            <div class="form-group">
                <lable class="col-md-1 control-label label-title">
                    <abbr style="font-weight:bold;">题名</abbr>
                </lable>
                <div class="col-md-2">
                    <input type="text" ng-model="searchForm.title" class="form-control"/>
                </div>
                <lable class="col-md-1 control-label label-title">
                    <abbr style="font-weight:bold;">上传日期</abbr>
                </lable>
                <div class="col-md-2">
                    <div class="c-datepicker-date-editor  J-datepicker-range-day mt10">
                        <i class="c-datepicker-range__icon kxiconfont icon-clock"></i>
                        <input placeholder="开始日期" name="" id="startTime" class="c-datepicker-data-input only-date"
                               value="">
                        <span class="c-datepicker-range-separator">-</span>
                        <input placeholder="结束日期" name="" id="overTime" class="c-datepicker-data-input only-date"
                               value="">
                    </div>
                </div>
                {#                <lable class="col-md-1 control-label label-title">#}
                {#                    <abbr style="font-weight:bold;">密级</abbr>#}
                {#                </lable>#}
                {#                <div class="col-md-2">#}
                {#                    <select class="form-control" ng-model="searchForm.secret" name="type"#}
                {#                            ng-options="item.id as item.realname for item in totalAdmin">#}
                {#                        <option value="">请选择密级</option>#}
                {#                    </select>#}
                {#                </div>#}

                {#                <lable class="col-md-1 control-label label-title">#}
                {#                    <abbr style="font-weight:bold;">保存期限</abbr>#}
                {#                </lable>#}
                {#                <div class="col-md-2">#}
                {#                    <select class="form-control" ng-model="searchForm.stroage" name="type"#}
                {#                            ng-options="item.id as item.realname for item in totalAdmin">#}
                {#                        <option value="">请选择保存期限</option>#}
                {#                    </select>#}
                {#                </div>#}
                <lable class="col-md-1 control-label label-title">
                    <abbr style="font-weight:bold;">责任人</abbr>
                </lable>
                <div class="col-md-2">
                    <input type="text" ng-model="searchForm.charge" class="form-control"/>
                </div>
                <lable class="col-md-1 control-label label-title">
                    <abbr style="font-weight:bold;">年度</abbr>
                </lable>
                <div class="col-md-2">
                    <input type="number" ng-model="searchForm.year" class="form-control"/>
                </div>

            </div>
            <div class="form-group">
                {#                <lable class="col-md-1 control-label label-title">#}
                {#                    <abbr style="font-weight:bold;">分类</abbr>#}
                {#                </lable>#}
                {#                <div class="col-md-2">#}
                {#                    <select class="form-control" ng-model="searchForm.classify" name="type"#}
                {#                            ng-options="item.id as item.realname for item in totalAdmin">#}
                {#                        <option value="">请选择分类</option>#}
                {#                    </select>#}
                {#                </div>#}

                <div class="col-md-12" style="text-align: right">
                    <button class="btn btn-info" ng-click="confimSearch(searchForm)">查询</button>
                    <button class="btn btn-info" ng-click="cancle()">取消</button>
                </div>
            </div>
        </form>
    </div>
    <div class="officeContent">
        <div class="operationBtn row">
            <div class="pull-right">
                <button class="btn btn-info" ng-click="newFile()"><i class="fa fa-plus-square-o icon"></i>新建</button>
                <button class="btn btn-info" data-toggle="modal" data-target="#uploadFile"><i
                        class="fa fa-upload icon"></i>上传
                </button>
                <button class="btn btn-info" ng-click="deleteUser()">扫描文件</button>
                <button class="btn btn-info" ng-click="achiveFile()">归档</button>
                <button class="btn btn-info" ng-click="delete()">删除</button>
                <button class="btn btn-info" ng-click="exportFile()">导出</button>
            </div>
        </div>
        <div class="officeTable">
            <table class="col-sm-12 table table-striped tabList">
                <thead>
                <tr>
                    <th width="3%"><input type="checkbox"></th>
                    <th width="15%">标题</th>
                    <th width="7%">文件数</th>
                    <th width="10%">大小</th>
                    <th width="9%">责任人</th>
                    <th width="10%">年度</th>
                    <th width="10%">密级</th>
                    <th width="13%">归档标识</th>
                    <th width="14%">备注</th>
                    <th width="9%" style="text-align: left">操作</th>
                </tr>
                </thead>
                <tbody>
                <tr ng-repeat="item in dataList1">
                    <td><input type="checkbox"></td>
                    <td class="pointer" ng-click="secondFolder(item.is_doc,item.id)" title="{$ item.name $}">
                        <i class="fa fa-file-text-o" ng-if="item.is_doc"></i>
                        <i class="fa fa-folder-o" ng-if="!item.is_doc"></i>{$ item.name $}
                    </td>
                    <td ng-bind="item.count"></td>
                    <td ng-bind="item.size"></td>
                    <td ng-bind="item.create_user"></td>
                    <td ng-bind="item.create_time"></td>
                    <td ng-bind="item.secrecy"></td>
                    <td ng-bind="item.archived"></td>
                    <td ng-bind="item.description"></td>
                    <td class="pointer" title="操作" style="position: relative;text-align: left">
                        <span style="color:#49cff6;" ng-click="showOperation(item.uid)"><i
                                class="fa fa-hand-paper-o icon"></i></span>
                        <div class="optionType " ng-show="optionTypeShow == item.uid">
                            <ul>
                                <li ng-click="download(item.id)" ng-if="item.is_doc">下载</li>
                                <li ng-click="share(item.id,item.name)">分享</li>
                                <li ng-click="rename()">重命名</li>
                                <li ng-click="moveTo()">移动到</li>
                                <li ng-click="printing()" ng-if="item.is_doc">打印</li>
                                <li ng-click="delete()" ng-if="item.is_doc">删除</li>
                            </ul>
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <div id="demo7" class="pag"></div>
    </div>
</div>
<div class="modal fade" id="uploadFile" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content" style="background-color: #EFF3FC;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    上传文件
                </h4>
            </div>
            <div class="modal-body">
                <div id="uploader" class="wu-example">
                    <!--用来存放文件信息-->
                    <div id="thelist" class="uploader-list"></div>
                    <div class="btns">
                        <div id="picker">选择文件</div>
                        <button id="ctlBtn" class="btn btn-default">开始上传</button>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="confimUpload">确定</button>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript" src="/static/assets/js/jquery-3.1.0.js"></script>
<script type="text/javascript" src="/static/assets/js/bui-min.js"></script>
<script type="text/javascript" src="/static/plugins/angular/angular.min.js"></script>
<script type="text/javascript" src="/static/datepicker/js/datepicker.all.js"></script>
<script type="text/javascript" src="/static/assets/js/config-min.js"></script>
<script type="text/javascript" src="/static/plugins/layui/js/layui.js"></script>
<script type="text/javascript" src="/static/plugins/PNotify/pnotify.custom.min.js"></script>
<script type="text/javascript" src="/static/plugins/pnotify.js"></script>
<script type="text/javascript" src="/static/datepicker/js/moment.min.js"></script>
<script type="text/javascript" src="/static/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/static/webuploader/webuploader.js"></script>
<script type="text/javascript" src="/static/plugins/angular-ui/ui-bootstrap-tpls.min.js">

</script>
<script type="text/javascript">
    var classes = {{ classes }};
    var folder_id = null;
    var app = angular.module('logMag', ['soc.PNotify', 'ui.bootstrap']);
    app.config(function ($interpolateProvider) {
        $interpolateProvider.startSymbol('{$');
        $interpolateProvider.endSymbol('$}');
    });

    app.controller('logManageCtrl', function ($scope, $http, serPNotify, $modal, $rootScope) {

        $scope.optionTypeShow = '';
        $scope.showHeightSearch = false;

        $scope.showSearch = true;
        $scope.searchForm = {
            title: "",
            year: "",
            charge: "",
            {#            classify: "",#}
            {#            secret: "",#}
            {#            stroage: "",#}
        };

        $scope.totalAdmin = [
            {"id": 1, "realname": "1223"},
            {"id": 2, "realname": "1223"},
            {"id": 3, "realname": "1223"},
            {"id": 4, "realname": "1223"},
            {"id": 5, "realname": "1223"},
        ];

        var state = 'pending';
        var uploader;
        $("#ctlBtn").on('click', function () {
            if (state === 'uploading') {
                uploader.stop();
            } else {
                uploader.upload();
            }
        });
        $("#uploadFile").on("shown.bs.modal", function () {
            uploader.refresh();//在模态框加载完成之后执行重绘按钮的方法。
        });

        var uploader = WebUploader.create({
            // swf文件路径
            swf: '/static/webuploader/Uploader.swf',
            // 文件接收服务端。
            server: '/api/document/uploadfile',
            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '#picker',
            // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
            resize: false,
            chunked: false,
        });

        // 当有文件被添加进队列的时候
        uploader.on('fileQueued', function (file) {
            $('#thelist').append('<div id="' + file.id + '" class="item">' +
                '<h4 class="info">' + file.name + '</h4>' +
                '<p class="state">等待上传...</p>' +
                '</div>');
        });

        // 文件上传过程中创建进度条实时显示。
        uploader.on('uploadProgress', function (file, percentage) {
            var $li = $('#' + file.id),
                $percent = $li.find('.progress .progress-bar');

            // 避免重复创建
            if (!$percent.length) {
                $percent = $('<div class="progress progress-striped active">' +
                    '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                    '</div>' +
                    '</div>').appendTo($li).find('.progress-bar');
            }

            $li.find('p.state').text('上传中');

            $percent.css('width', percentage * 100 + '%');
        });

        var fileName = [];
        uploader.on('uploadSuccess', function (file, resp) {
            var size = file.size;
            if (size > 1024 * 1024 * 1024) {
                size = (file.size / (1024 * 1024 * 1024)).toFixed(2) + "GB";
            } else if (size > 1024 * 1024) {
                size = (file.size / (1024 * 1024)).toFixed(2) + "MB";
            } else if (size > 1024) {
                size = (file.size / (1024)).toFixed(2) + "KB";
            } else {
                size = file.size.toFixed(2) + "B";
            }
            fileName.push({
                "storage": resp.data.fileName,
                "name": file.name,
                "classes": classes,
                "size": size,
                "ext": file.ext,
                "folder_id": folder_id,
            });
            $('#' + file.id).find('p.state').text('已上传');
        });

        uploader.on('uploadError', function (file) {
            $('#' + file.id).find('p.state').text('上传出错');
        });

        uploader.on('uploadComplete', function (file) {
            $('#' + file.id).find('.progress').fadeOut();
        });


        //确认上传
        $("#confimUpload").on('click', function () {
            $("#thelist").html("");
            $("#uploadFile").modal('hide');
            $http({
                method: 'POST',
                url: '/api/document/createdoc',
                data: {"fileList": fileName},
            }).then(function successCallback(response) {
                $scope.dataList = response.data;
                $scope.DocList();
            }, function errorCallback(response) {
                serPNotify.error("接口请求失败");
            });
        });

        //获取列表数据
        $rootScope.DocList = function () {
            $http({
                url: '/api/document/doclist',
                method: "POST",
                data: {"classes": classes, "folder_id": folder_id}
            }).then(function (resp) {
                $scope.dataList = resp.data.data.totalDoc;
                $scope.navData = resp.data.data.totalPath;
                $scope.navData[0].name = "办公室";
                //分页
                layui.use(['laypage', 'layer'], function () {
                    var laypage = layui.laypage
                        , layer = layui.layer;
                    laypage.render({
                        elem: 'demo7'
                        , count: $scope.dataList.length
                        , layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
                        , jump: function (obj) {
                            //obj.curr得到当前页，以便向服务端请求对应页的数据。
                            //obj.limit得到每页显示的条数
                            $scope.dataList1 = $scope.dataList.slice((obj.curr - 1) * obj.limit, obj.curr * obj.limit);
                            console.log($scope.dataList1[0]);
                            $scope.$applyAsync();
                        }
                    });
                })
            }, function (err) {
                serPNotify.error("接口请求失败");
            });
        };
        $rootScope.DocList();

        //文件夹下钻
        $scope.secondFolder = function (type, id) {
            folder_id = id;
            if (type == true) {
                console.log("文件")
            } else {
                $http({
                    method: 'POST',
                    url: '/api/document/doclist',
                    data: {"classes": classes, "folder_id": folder_id},
                }).then(function successCallback(response) {
                    $scope.dataList = response.data.data.totalDoc;
                    $scope.navData = response.data.data.totalPath;
                    $scope.navData[0].name = "办公室";
                    //分页
                    layui.use(['laypage', 'layer'], function () {
                        var laypage = layui.laypage
                            , layer = layui.layer;
                        laypage.render({
                            elem: 'demo7'
                            , count: $scope.dataList.length
                            , layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
                            , jump: function (obj) {
                                //obj.curr得到当前页，以便向服务端请求对应页的数据。
                                //obj.limit得到每页显示的条数
                                $scope.dataList1 = $scope.dataList.slice((obj.curr - 1) * obj.limit, obj.curr * obj.limit);
                                {#                            $scope.$digest();#}
                                $scope.$applyAsync();
                            }
                        });
                    })
                }, function errorCallback(response) {
                    serPNotify.error("接口请求失败");
                });
            }
        };

        //面包屑跳转
        $scope.navHref = function (id) {
            folder_id = id;
            $http({
                method: 'POST',
                url: '/api/document/doclist',
                data: {"classes": classes, "folder_id": folder_id},
            }).then(function successCallback(response) {
                $scope.dataList = response.data.data.totalDoc;
                $scope.navData = response.data.data.totalPath;
                $scope.navData[0].name = "办公室";
                //分页
                layui.use(['laypage', 'layer'], function () {
                    var laypage = layui.laypage
                        , layer = layui.layer;
                    laypage.render({
                        elem: 'demo7'
                        , count: $scope.dataList.length
                        , layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
                        , jump: function (obj) {
                            //obj.curr得到当前页，以便向服务端请求对应页的数据。
                            //obj.limit得到每页显示的条数
                            $scope.dataList1 = $scope.dataList.slice((obj.curr - 1) * obj.limit, obj.curr * obj.limit);
                            {#                            $scope.$digest();#}
                            $scope.$applyAsync();
                        }
                    });
                })
            }, function errorCallback(response) {
                serPNotify.error("接口请求失败");
            });
        }

        //简单查询
        $scope.searchSimple = function () {
            $http({
                method: 'POST',
                url: '/api/document/query',
                data: {"title": $scope.title, "charge": $scope.personCharge},
            }).then(function successCallback(response) {
                $scope.dataList = response.data.data;
                //分页
                layui.use(['laypage', 'layer'], function () {
                    var laypage = layui.laypage
                        , layer = layui.layer;
                    laypage.render({
                        elem: 'demo7'
                        , count: $scope.dataList.length
                        , layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
                        , jump: function (obj) {
                            //obj.curr得到当前页，以便向服务端请求对应页的数据。
                            //obj.limit得到每页显示的条数
                            $scope.dataList1 = $scope.dataList.slice((obj.curr - 1) * obj.limit, obj.curr * obj.limit);
                            {#                            $scope.$digest();#}
                            $scope.$applyAsync();
                        }
                    });
                })
            }, function errorCallback(response) {
                serPNotify.error("接口请求失败");
            });
        }
        //高级查询模块显示
        $scope.heightSearch = function () {
            if ($scope.showHeightSearch == true) {
                $scope.showHeightSearch = false;
                $scope.showSearch = true;
            } else {
                $scope.showHeightSearch = true;
                $scope.showSearch = false;
            }
        };
        //確定高級查詢
        $scope.confimSearch = function (form) {
            //判断结束时间大于开始时间
            var startTime = $("#startTime").val();
            var overTime = $("#overTime").val();
            var data = {
                startTime: startTime,
                overTime: overTime
            };
            var form = angular.extend(form, data);
            $http.post('/api/document/filterquery', form).then(
                function (resp) {
                    serPNotify.success("搜索成功");
                    $scope.dataList = resp.data.data;
                    //分页
                    layui.use(['laypage', 'layer'], function () {
                        var laypage = layui.laypage
                            , layer = layui.layer;
                        laypage.render({
                            elem: 'demo7'
                            , count: $scope.dataList.length
                            , layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
                            , jump: function (obj) {
                                //obj.curr得到当前页，以便向服务端请求对应页的数据。
                                //obj.limit得到每页显示的条数
                                $scope.dataList1 = $scope.dataList.slice((obj.curr - 1) * obj.limit, obj.curr * obj.limit);
                                {#                            $scope.$digest();#}
                                $scope.$applyAsync();
                            }
                        });
                    })
                },
                function (resp) {
                    serPNotify.error("接口请求失败");
                });

        }

        $scope.cancle = function () {
            $scope.showHeightSearch = false;
            $scope.showSearch = true;
        };

        //分享
        var params = {
            id: "",
            title: ""
        }


        //新建文件
        $scope.newFile = function () {
            $modal.open({
                templateUrl: '/static/html/document/newFile.html',
                controller: 'newFileCtrl',
                scope: $scope,
            });
        };

        //下载文件
        $scope.download = function (id) {
            $http({
                method: 'POST',
                url: '/api/document/downloadfile',
                data: {"id": id},
            }).then(function successCallback(response) {
                // $scope.dataList = response.data.data;
                 var path = response.data;
                 console.log(response.path)
                 location.href = path
            }, function errorCallback(response) {
                serPNotify.error("接口请求失败");
            });
        };

        $scope.showOperation = function (type) {
            $scope.optionTypeShow = type;
        };
        $scope.share = function (id, name) {
            $scope.optionTypeShow = '';
            $modal.open({
                templateUrl: '/static/html/myShare/shareChance.html',
                controller: 'shareChanceCtrl',
                scope: $scope,
                resolve: {
                    params: function () {
                        params.id = id;
                        params.title = name;
                        return params;
                    }
                }
            });
        };
        $(function () {
            var DATAPICKERAPI = {
                // 默认input显示当前月,自己获取后填充
                activeMonthRange: function () {
                    return {
                        begin: moment().set({
                            'date': 1,
                            'hour': 0,
                            'minute': 0,
                            'second': 0
                        }).format('YYYY-MM-DD HH:mm:ss'),
                        end: moment().set({'hour': 23, 'minute': 59, 'second': 59}).format('YYYY-MM-DD HH:mm:ss')
                    }
                },
                shortcutMonth: function () {
                    // 当月
                    var nowDay = moment().get('date');
                    var prevMonthFirstDay = moment().subtract(1, 'months').set({'date': 1});
                    var prevMonthDay = moment().diff(prevMonthFirstDay, 'days');
                    return {
                        now: '-' + nowDay + ',0',
                        prev: '-' + prevMonthDay + ',-' + nowDay
                    }
                },
                // 快捷选项option
                rangeShortcutOption1: [{
                    name: '最近一周',
                    day: '-7,0'
                }, {
                    name: '最近一个月',
                    day: '-30,0'
                }, {
                    name: '最近三个月',
                    day: '-90, 0'
                }],
            };
            //年月日范围
            $('.J-datepicker-range-day').datePicker({
                hasShortcut: true,
                format: 'YYYY-MM-DD',
                isRange: true,
                shortcutOptions: DATAPICKERAPI.rangeShortcutOption1
            });
        });

    })
    //新建文件的模态框
    app.controller('newFileCtrl', function ($scope, $modalInstance, $http, $rootScope, serPNotify) {
        $scope.folderForm = {
            foldername: "",
            folder_id: folder_id,
            classes: classes,
        };
        $scope.confirm = function () {
            $modalInstance.close();
            $http({
                method: 'POST',
                url: '/api/document/createfolder',
                data: $scope.folderForm
            }).then(function successCallback(response) {
                $rootScope.DocList();
            }, function errorCallback(response) {
                // 请求失败执行代码
                serPNotify.error("添加失败");
            });
        };
        $scope.cancel = function () {
            $modalInstance.dismiss();
        };
    });

    //分享选择的模态框
    app.controller('shareChanceCtrl', function ($scope, $modalInstance, $http, $rootScope, serPNotify, params) {
        $scope.title = params.title;
        $scope.shareWith = {
            fileID: params.id,
            treeID: "",
            treeLevel: ""
        }
        //获取树结构数据
        $scope.treeData = function () {
            $http.post('/api/orginazation/getorguser').then(
                function (resp) {
                    $scope.tree_data = resp.data.data;
                    BUI.use('bui/tree', function (Tree) {
                        var tree = new Tree.TreeList({
                            render: '#ToShare',
                            nodes: $scope.tree_data
                        });
                        tree.render();
                        tree.on('itemclick', function (ev) {
                            var item = ev.item;
                            console.log("item", item);
                            $scope.shareWith.treeID = item.id;
                            $scope.shareWith.treeLevel = item.level;
                            $('.log').text(item.level);
                        });
                    });
                },
                function (resp) {
                    alert("接口请求失败");
                });
        };
        $scope.treeData();
        $scope.confirm = function () {
            $modalInstance.close();
            $http({
                method: 'POST',
                url: '/api/share/adddoc',
                data: $scope.shareWith
            }).then(function successCallback(response) {

            }, function errorCallback(response) {
                // 请求失败执行代码
                serPNotify.error("分享失败");
            });
        };
        $scope.cancel = function () {
            $modalInstance.dismiss();
        };
    });
</script>
</body>
</html>